package presenters.test

class AssertableBuilder extends BuilderSupport {

    def nodesCalled = []

    protected void setParent(Object o, Object o1) {
    }

    protected Object createNode(Object o) {
        nodesCalled << new TestNode(o.toString())
    }

    protected Object createNode(Object node, Object o1) {
        nodesCalled << new TestNode(node.toString(), o1)
    }

    protected Object createNode(Object node, Map map) {
        nodesCalled << new TestNode(node.toString(), map)
    }

    protected Object createNode(Object node, Map map, Object o1) {
        nodesCalled << new TestNode(node.toString(), map, o1)
    }

    def hasNodeWith(map) {
        def name = map.name
        def value = map.value
        def matchedNode = nodesCalled.find {node ->
            node.nodeName == name && node.value == value
        }
        return matchedNode?true:false
    }

}